package myschool.myshchool15.homework;

import java.util.Scanner;

public class GiveChange {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("**************************************");
        System.out.println("请选择购买的商品编号：");
        System.out.println("1、T恤\t2、网球鞋\t3、网球拍");
        System.out.println("**************************************");
        String yes="y";
        int number;
        int buyNumber;
        double sum = 0;
        while( yes.equals("y")){
            System.out.println("请输入商品编号：");
            number = input.nextInt();
            System.out.println("请输入购买数量：");
            buyNumber = input.nextInt();
            switch(number){
                case 1:
                    System.out.print("T恤￥245.0\t\t");
                    System.out.print("数量"+buyNumber+"\t");
                    sum = sum+(245.0*buyNumber);
                    System.out.println("合计￥"+sum);
                    break;
                case 2:
                    System.out.print("网球鞋￥570.0\t\t");
                    System.out.print("数量"+buyNumber+"\t");
                    sum = sum+(570*buyNumber);
                    System.out.println("合计￥"+sum);
                    break;
                case 3:
                    System.out.print("网球拍￥320.0\t\t");
                    System.out.print("数量"+buyNumber+"\t");
                    sum = sum+(320*buyNumber);
                    System.out.println("合计￥"+sum);
                    break;
                default:
                    System.out.println("请输入正确的编号！");
            };
            System.out.println("是否继续（y/n）");
            yes = input.next();

        }
        double discount;
        System.out.println("折扣");
        discount = input.nextDouble();
        System.out.println("应付金额："+(sum*discount));
        double money;
        System.out.println("实付金额：");
        money = input.nextDouble();
        System.out.println("找钱："+(money-(sum*discount)));

    }
}
